{include file="public/head" /}
<style>
    body {background-color: #333;}
    label, h1 {color: #fff}
    form{margin-top: 10%}
    h1{text-align: center;margin-bottom: 20px}

</style>
</head>
<body>
<div class="layui-container">
<form class="layui-form layui-col-xs6 layui-col-xs-offset3" action="">
    <h1>学校宿舍管理系统</h1>
    <div class="layui-form-item">
        <input type="text" name="username" lay-verify="required" placeholder="用户名" autocomplete="off"
               class="layui-input">
    </div>
    <div class="layui-form-item">
        <input type="password" name="password" lay-verify="required" placeholder="密码" autocomplete="off"
               class="layui-input">
    </div>

    <div style="text-align: center">
        <a class="layui-btn" lay-submit="" lay-filter="login">登录</a>
    </div>
</form>
</div>
<script>
    layui.use('form', function () {
        var form = layui.form, layer = layui.layer;
        //表单提交
        form.on('submit(login)', function (data) {
            $.post("{:url('admin/Login/doLogin')}", {data: data.field}, function (res) {
                if (res.code == 0) {
                    layer.msg(res.msg, {time: 2000, icon: 5});
                } else {
                    layer.msg(res.msg, {time: 1500, icon: 6});
                    setTimeout(function () {
                        window.location.href = "{:url('admin/Index/index')}";
                    }, 1500)
                }
            }, "json");
        });
    });
</script>
</body>
</html>